/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIDice.java
 *
 * Created on Apr 15, 2011, 4:29:17 PM
 */
package horsechess.client.gui;

import javax.swing.JPanel;

/**
 *
 * @author Administrator
 */
public class GUIDice extends JPanel {

    /**
     * Getter && Settter
     */
    public int getNumberOfDice() {
        return numberOfDice;
    }

    public void setNumberOfDice(int numberOfDice) {
        this.numberOfDice = numberOfDice;
    }

    /** Creates new form GUIDice */
    public GUIDice() {
        initComponents();
        numberOfDice=1;
        loadImageDice(1, 6);
        localizeDice();
    }
    /** Creates new form GUIDice based on number of dice */
    public  GUIDice(int numOfDice)
    {
        initComponents();
        numberOfDice=numOfDice;
        loadImageDice(1, 6);
        localizeDice();
    }
    /**
     * Locate the dice on the board
     */
    public void localizeDice() {
        if (numberOfDice == 1) {
            this.picDice1.setBounds(32, 8,40,40);
            if (picDice2.isVisible()) {
                picDice2.setVisible(false);
            }
        } else {

            picDice1.setBounds(8, 8,40,40);
             if (!picDice2.isVisible()) {
                picDice2.setVisible(true);
            }
        }
    }

    public void loadImageDice1(int value){
        picDice1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/"+value+".JPG")));
    }
     public void loadImageDice2(int value){
         picDice2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/"+value+".JPG")));
    }
    /**
     * Load dice image based on value of dice on board. The range of value from 1 to 9
     * @param value1
     * @param value2
     */
    public void loadImageDice(int value1, int value2)
    {
           picDice1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/"+value1+".JPG")));
           picDice2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/"+value2+".JPG")));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        picDice1 = new javax.swing.JLabel();
        picDice2 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setMaximumSize(new java.awt.Dimension(104, 40));
        setMinimumSize(new java.awt.Dimension(104, 40));
        setPreferredSize(new java.awt.Dimension(104, 56));
        setLayout(null);

        picDice1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/1.JPG"))); // NOI18N
        picDice1.setAlignmentX(0.8F);
        picDice1.setAlignmentY(0.8F);
        picDice1.setRequestFocusEnabled(false);
        add(picDice1);
        picDice1.setBounds(8, 8, 40, 40);

        picDice2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/dice/2.JPG"))); // NOI18N
        add(picDice2);
        picDice2.setBounds(56, 8, 40, 40);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel picDice1;
    private javax.swing.JLabel picDice2;
    // End of variables declaration//GEN-END:variables
    private int numberOfDice;
}
